package com.taikang.pms.service.impl;


import com.taikang.base.service.BaseServiceImpl;
import com.taikang.pms.dao.CommunityDAO;
import com.taikang.pms.entity.Community;
import com.taikang.pms.service.CommunityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import static com.google.common.base.Preconditions.checkNotNull;


@Service("communityService")
public class CommunityServiceImpl extends BaseServiceImpl implements CommunityService {

    @Autowired
    private CommunityDAO communityDAO;

    @Transactional
    public void saveOrUpdate(Community community) {
        checkNotNull(community, "Community must be not null.");
        if (community.getId() == null) {
            communityDAO.insert(community);
        } else {
            communityDAO.updateByPrimaryKey(community);
        }
    }
}
